# Maintainer: Christian Hesse <mail@eworm.de>

pkgname=yubikey-personalization
_shortname=ykpers
pkgver=1.20.0
pkgrel=3
pkgdesc='Yubico YubiKey Personalization library and tool'
arch=('loong64' 'x86_64')
url='https://github.com/Yubico/yubikey-personalization'
license=('BSD')
depends=('libusb' 'json-c' 'yubico-c-client')
# We need systemd to be installed for udev version check
makedepends=('systemd')
provides=('ykpers')
conflicts=('ykpers')
validpgpkeys=('0A3B0262BCA1705307D5FF06BCA00FD4B2168C0A') # Klas Lindfors <klas@yubico.com>
source=("https://developers.yubico.com/${pkgname}/Releases/${_shortname}-${pkgver}.tar.gz"{,.sig}
        '0001-fix-boolean-value-with-json-c-0.14.patch')
sha256sums=('0ec84d0ea862f45a7d85a1a3afe5e60b8da42df211bb7d27a50f486e31a79b93'
            'SKIP'
            'f9b434e9570ce7d0192182aab979f767238b704f12645546e567db841bb7b5e2')

prepare() {
	cd "${_shortname}-${pkgver}"

	patch -Np1 < ../0001-fix-boolean-value-with-json-c-0.14.patch
}

build() {
	cd "${_shortname}-${pkgver}"

	./configure \
		--prefix=/usr \
		--with-udevrulesdir=/usr/lib/udev/rules.d/
	make
}

check() {
	cd "${_shortname}-${pkgver}"

	make check
}

package() {
	cd "${_shortname}-${pkgver}"

	install -D -m0644 COPYING "${pkgdir}/usr/share/licenses/yubikey-personalization/COPYING"
	install -D -m0644 README "${pkgdir}/usr/share/doc/yubikey-personalization/README"
	make DESTDIR="${pkgdir}/" install
}

